Function: c-backward-<>-arglist

c-backward-<>-arglist is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-backward-<>-arglist ALL-TYPES &optional LIMIT RESTRICTED-FUNCTION)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-backward-<>-arglist (all-types &optional limit restricted-function)
  ;; The point is assumed to be directly after a ">".  Try to treat it
  ;; as the close paren of an angle bracket arglist and move back to
  ;; the corresponding "<".  If successful, the point is left at
  ;; the "<" and t is returned, otherwise the point isn't moved and
  ;; nil is returned.  ALL-TYPES is passed on to
  ;; `c-forward-<>-arglist'.
  ;;
  ;; If the optional LIMIT is given, it bounds the backward search.
  ;; It's then assumed to be at a syntactically relevant position.  If
  ;; RESTRICTED-FUNCTION is non-nil, it should be a function taking no
  ;; arguments, called with point at a < at the start of a purported
  ;; <>-arglist, which will return the value of
  ;; `c-restricted-<>-arglists' to be used in the `c-forward-<>-arglist'
  ;; call starting at that <.
  ;;
  ;; This is a wrapper around `c-forward-<>-arglist'.  See that
  ;; function for more details.

  (let ((start (point)))
    (backward-char)
    (if (and (not c-parse-and-markup-<>-arglists)
	     (c-get-char-property (point) 'syntax-table))

	(if (and (c-go-up-list-backward)
		 (eq (char-after) ?<))
	    t
	  ;; See corresponding note in `c-forward-<>-arglist'.
	  (goto-char start)
	  nil)

      (while (progn
	      (c-syntactic-skip-backward "^<;{}" limit t)

	      (and
	       (if (eq (char-before) ?<)
		   t
		 ;; Stopped at bob or a char that isn't allowed in an
		 ;; arglist, so we've failed.
		 (goto-char start)
		 nil)

	       (if (> (point)
		      (progn (c-beginning-of-current-token)
			     (point)))
		   ;; If we moved then the "<" was part of some
		   ;; multicharacter token.
		   t

		 (backward-char)
		 (let ((beg-pos (point))
		       (c-restricted-<>-arglists
			(if restricted-function
			    (funcall restricted-function)
			  c-restricted-<>-arglists)))
		   (if (c-forward-<>-arglist all-types)
		       (cond ((= (point) start)
			      ;; Matched the arglist.  Break the while.
			      (goto-char beg-pos)
			      nil)
			     ((> (point) start)
			      ;; We started from a non-paren ">" inside an
			      ;; arglist.
			      (goto-char start)
			      nil)
			     (t
			      ;; Matched a shorter arglist.  Can be a nested
			      ;; one so continue looking.
			      (goto-char beg-pos)
			      t))
		     t))))))

      (/= (point) start))))